#include <stdio.h>

int partition(int a[],int low,int high){
    int pirot=a[low];
    while (low<high)
    {
        while (low<high&&a[high]>=pirot)
        {
            high--;
        }
        a[low]=a[high];
        while (low<high&&a[low]<=pirot)
        {
            low++;
        }
        a[high]=a[low];
    }
    a[low]=pirot;  //填补空的位置
    return low;  
}

void QuickSort(int a[],int low,int high){
    if (low<high)
    {
        int pos=partition(a,low,high);
        QuickSort(a,low,pos-1);  //递归调用
        QuickSort(a,pos+1,high);
    }
    
}
int main(int argc, char const *argv[])
{
    int a[]={12,34,99,22,43,53,5,88};
    QuickSort(a,0,sizeof(a)/sizeof(a[0])-1);         //low是从0开始的
    for (size_t i = 0; i < sizeof(a)/sizeof(a[0]); i++)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}
